CUBE CONNECT Edition Help

Obtaining a list of links for a network

The links() method allows to retrieve the links of the network in a CubeNetworkEntityResultSet. This is an iterable object where the cursor is set to a record initialized before the first record.
net_links = db.links(network_name)
net_links_list = []
while net_links.next():
    net_links_list.append([net_links.a(), net_links.b()])

Alternatively, a Lua expression can be used, to retrieve the links A and B numbers using the valueForLinks() method. An example is provided below, where string concatenation operator is done in Lua with ".." (two dots):

lua_expr = '__userDataString1 = __userDataString1 .. ", " .. link.a .. "-" .. link.b'
link_value = db.valueForLinks(network_name, lua_expr)  
links_string = [item.split("-") for item in list(db.lastExpressionUserData().string1[2:].split(","))]
links_list = [list(map(int, nest)) for nest in links_string]

This will return a nested Python list with the integer A and B nodes of each link.